package entity;

import entity.CRM.ProductPrice;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javaclass.ProductCategory;
import javaclass.ProductType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;

@Entity
public class Product implements Serializable {
    @Id
    private ProductType productType;
    private String description;
    private ProductCategory productCategory;
    private Double weightPerBar;
    private Long capacityPerMinutes;
    private Long packingBarsPerDisplayBox;
    private Long productionLineChangeOverInMins;
    private Long defaultPrice;
    
    @OneToMany
    private List<ProductPrice> productPrices = new ArrayList<ProductPrice>();
//    @OneToOne
//    private ProductBalance productBalance = new ProductBalance;

    public Long getCapacityPerMinutes() {
        return capacityPerMinutes;
    }

    public void setCapacityPerMinutes(Long capacityPerMinutes) {
        this.capacityPerMinutes = capacityPerMinutes;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Long getPackingBarsPerDisplayBox() {
        return packingBarsPerDisplayBox;
    }

    public void setPackingBarsPerDisplayBox(Long packingBarsPerDisplayBox) {
        this.packingBarsPerDisplayBox = packingBarsPerDisplayBox;
    }

    public ProductCategory getProductCategory() {
        return productCategory;
    }

    public void setProductCategory(ProductCategory productCategory) {
        this.productCategory = productCategory;
    }

    public List<ProductPrice> getProductPrices() {
        return productPrices;
    }

    public void setProductPrices(List<ProductPrice> productPrices) {
        this.productPrices = productPrices;
    }

    public ProductType getProductType() {
        return productType;
    }

    public void setProductType(ProductType productType) {
        this.productType = productType;
    }

    public Long getProductionLineChangeOverInMins() {
        return productionLineChangeOverInMins;
    }

    public void setProductionLineChangeOverInMins(Long productionLineChangeOverInMins) {
        this.productionLineChangeOverInMins = productionLineChangeOverInMins;
    }

    public Double getWeightPerBar() {
        return weightPerBar;
    }

    public void setWeightPerBar(Double weightPerBar) {
        this.weightPerBar = weightPerBar;
    }
    
    public Long getCapacityBarsPerHour(){
        return this.getCapacityPerMinutes() * 60;
    }
    
    public Long getCapacityKgPerHour(){
        return Math.round(this.getWeightPerBar() / 1000 * this.getCapacityPerMinutes() * 60);
    }
    
    public Long getPackingBarsPerShippingCase(){
        return this.getPackingBarsPerDisplayBox() * 10;
    }
    
    public Long getCapacityCasesPerHour(){
        return this.getCapacityBarsPerHour()/this.getPackingBarsPerShippingCase();
    }

    public Double getKgPerCase(){
        return (double)this.getCapacityKgPerHour()/(double)this.getCapacityCasesPerHour();
    }
    
    public Long getDefaultPrice() {
        return defaultPrice;
    }

    public void setDefaultPrice(Long defaultPrice) {
        this.defaultPrice = defaultPrice;
    }
    
}
